// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 

package pica.core;

import java.io.UnsupportedEncodingException;
import java.util.Hashtable;

final class c
{

    public c(String s)
        throws Exception, UnsupportedEncodingException
    {
        d = new Hashtable();
        g = 0;
        a = false;
        h = s;
        i = 0;
    }

    private int d()
    {
        if(i >= h.length())
            return -1;
        else
            return h.charAt(i++);
    }

    public final int a()
        throws Exception
    {
        f = e;
        e = d();
        if(e <= 32)
            while((e = d()) <= 32 && e != -1) ;
        if(e == -1)
        {
            g = 1;
            return g;
        }
        if(e == 60 || f == 60 && e == 47 && !a)
        {
            a = true;
            b = null;
            c = null;
            d.clear();
            if(e == 60)
                e = d();
            if(e == 47)
            {
                g = 3;
                e = d();
                b = b(62);
            } else
            if(e == 63 || e == 33)
            {
                while((e = d()) != 62) ;
                a();
            } else
            {
                g = 2;
                b = b(32);
                Object obj = null;
                Object obj1 = null;
                while(e == 32) 
                {
                    e = d();
                    String s = b(61);
                    e = d();
                    e = d();
                    String s1;
                    if(e == 39)
                        s1 = "";
                    else
                        s1 = a(39);
                    e = d();
                    d.put(s, s1);
                }
                if(e != 47)
                    a = false;
            }
        } else
        if(e == 62 && a)
        {
            g = 3;
            a = false;
        } else
        {
            b = null;
            d.clear();
            g = 4;
            c = a(60);
        }
        return g;
    }

    public final String b()
    {
        return b;
    }

    public final String a(String s)
    {
        return (String)d.get(s);
    }

    public final String c()
    {
        return c;
    }

    private String a(int j)
        throws Exception
    {
        StringBuffer stringbuffer = new StringBuffer("");
        do
        {
            if(e == 38)
            {
                e = d();
                switch(e)
                {
                case 108: // 'l'
                    stringbuffer.append('<');
                    break;

                case 103: // 'g'
                    stringbuffer.append('>');
                    break;

                case 97: // 'a'
                    if(d() == 109)
                        stringbuffer.append('&');
                    else
                        stringbuffer.append('\'');
                    break;

                case 113: // 'q'
                    stringbuffer.append('"');
                    break;

                case 110: // 'n'
                    stringbuffer.append(' ');
                    break;

                default:
                    stringbuffer.append('?');
                    break;
                }
                while((e = d()) != 59) ;
                continue;
            }
            if(e == 92)
            {
                e = d();
                if(e == j)
                {
                    stringbuffer.append('\\');
                    break;
                }
                if(e == 38)
                {
                    stringbuffer.append('\\');
                    continue;
                }
                if(e == 60)
                {
                    stringbuffer.append('\\');
                    break;
                }
                if(e == 92)
                {
                    stringbuffer.append("\\\\");
                } else
                {
                    stringbuffer.append('\\');
                    stringbuffer.append((char)e);
                }
            } else
            {
                stringbuffer.append((char)e);
            }
        } while((e = e == 38 ? 38 : d()) != j);
        String s = "";
        try
        {
            s = stringbuffer.toString();
        }
        catch(Exception _ex) { }
        return s;
    }

    private String b(int j)
        throws Exception
    {
        StringBuffer stringbuffer = new StringBuffer("");
        do
            stringbuffer.append((char)e);
        while((e = d()) != j && e != 62 && e != 47);
        return stringbuffer.toString();
    }

    private boolean a;
    private String b;
    private String c;
    private Hashtable d;
    private int e;
    private int f;
    private int g;
    private String h;
    private int i;
}
